package com.pengcheng.test;

import io.netty.channel.Channel;

import java.util.ArrayList;
import java.util.List;

public class ChannelCache {
    public static List<Channel> list_channel=new ArrayList<>();
    public static void add(Channel channel){
        int index=find(channel);
        if(index==-1)
        {
            list_channel.add(channel);
        }
    }
    public static void remove(Channel channel)
    {
        int index=find(channel);
        if(index>=0)
        {
            list_channel.remove(index);
        }
    }
    public static int find(Channel channel)
    {
        int index=-1;
        for(int i=0;i< list_channel.size();i++)
        {
            if(list_channel.get(i).id().equals(channel.id()))
            {
                index=i;
                i=list_channel.size();
            }
        }
        return index;
    }
}
